package com.caicai.test4;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

public class IODemo1 extends IODemo {

	@Override
	public void code() {
//		try {
//			InputStream is=new FileInputStream("a.txt");
//			OutputStream os=new FileOutputStream("b.txt");
//			byte byts[]=new byte[1024];
//			int len=0;
//			while((len=is.read(byts))!=-1){
//				os.write(byts,0,len);
//			}
//			os.close();
//			is.close();
//		} catch (IOException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		}
		try {
			BufferedInputStream bis=new BufferedInputStream(new FileInputStream("a.txt"));
			BufferedOutputStream bos=new BufferedOutputStream(new FileOutputStream("b.txt"));
			byte bytes[]=new byte[1024];
			int len=0;
			while((len=bis.read(bytes))!=-1){
				bos.write(bytes,0,len);
			}
			bos.close();
			bis.close();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}
